<template>
  <div style="height: 35.4vw;" class="bannerPC">
    <el-carousel :interval="5000" arrow="always" height="35.4vw" @change="carouselChange">
      <el-carousel-item v-for="(item, index) in pageData.bannerList" :key="item" style="height: 35.4vw; width: 100%;">
        <div class="bannerBox">
          <div class="pageContainer">
            <div
              class="desc"
              :class="{active: activedTab == index }">
              <div class="text1" v-html="item.title"></div>
              <div class="line"></div>
              <div class="text2">{{item.descrip}}</div>
            </div>
          </div>
          <img style="height: 35.4vw; width: 100%;" :src="item.banner"/>
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
  <!--:autoplay="autoplay"-->
  <div class="solvePlanbannerMobile">
    <swiper
      :slides-per-view="1"
      :space-between="0"
      :modules="modules"
      :autoplay="autoplay"
      :loop="true"
      @swiper="onSwiper"
      @slideChange="onSlideChange"
      :thumbs="{ swiper: thumbsSwiper }"
    >
      <swiper-slide v-for="(item, index) in pageData.bannerList" :key="item" style="height: 35.4vw; width: 100%;">

        <div class="bannerBox">
          <div class="pageContainer">
            <div
              class="desc"
              :class="{active: activedTab == index }">
              <div class="text1" v-html="item.title"></div>
              <div class="line"></div>
              <div class="text2">{{item.descrip}}</div>
            </div>
          </div>
          <img style="height: 35.4vw; width: 100%;display: block;" :src="item.banner"/>
        </div>
      </swiper-slide>
    </swiper>


    <div class="thumsMobile" style="">
      <swiper
        v-if="pageData?.bannerList?.length > 0"
        :modules="[Thumbs]"
        :space-between="5"
        :slidesPerView="pageData?.bannerList?.length"
        watch-slides-progress
        @swiper="setThumbsSwiper"
      >
        <swiper-slide v-for="item in pageData.bannerList" :key="item"></swiper-slide>
      </swiper>
    </div>
  </div>
</template>

<script setup>
  import {ref} from 'vue'
  import {Swiper, SwiperSlide} from 'swiper/vue';
  import {Navigation, Pagination, Scrollbar, A11y, Autoplay, Thumbs} from 'swiper';
  import 'swiper/css';
  import "swiper/css/free-mode"
  import "swiper/css/navigation"
  import "swiper/css/thumbs"

  const activedTab = ref(0)
  const modules = [Navigation, Pagination, Scrollbar, A11y, Autoplay, Thumbs]

  let autoplay = {
    delay: 3000,
    stopOnLastSlide: false,
    disableOnInteraction: false,
  }
  const props = defineProps({
    pageData: {
      type: Object,
      default: () => {
      },
    }
  })
  const carouselChange = (val) => {
    activedTab.value = val
  }

  const onSwiper = (swiper) => {
    console.log(swiper);
  };
  const onSlideChange = () => {
    console.log('slide change');
  };

  const thumbsSwiper = ref(null);
  const setThumbsSwiper = (swiper) => {
    thumbsSwiper.value = swiper;
  }
</script>

<style lang="scss">
  .solvePlanbannerMobile {
    position: relative;
    .swiper-slide-active {
      .bannerBox {
        width: 100%;
        .pageContainer {
          .desc {
            left: 0;
            top: 0;
            transition: all 0.5s;
          }
        }
      }
    }

    .thumsMobile {
      position: absolute;
      left: 0;
      bottom: 10px;
      width: 100%;
      padding: 0 120px;
      .swiper-slide {
        border: 1px solid rgba(255, 255, 255, 0.2);
        &.swiper-slide-thumb-active {
          border: 1px solid rgba(255, 255, 255, 1);
        }
      }
    }
  }
</style>
<style scoped lang="scss">
  @media screen and (max-width: 1079px) {
    .bannerPC {
      display: none;
    }
    .solvePlanbannerMobile {
    }

    .bannerBox {
      width: 100%;
      .pageContainer {
        width: 80vw;
        margin: 0 auto;
        position: relative;
        .desc {
          position: absolute;
          left: 0;
          top: 35.4vw;
          color: #fff;
          height: 35.4vw;
          display: flex;
          flex-direction: column;
          transition: all 0.5s;
          justify-content: center;

          .text1 {
            font-size: 18px;
            font-weight: bold;
            line-height: 28px;
          }
          .line {
            width: 30px;
            border-bottom: 2px solid #fff;
          }
          .text2 {
            font-size: 14px;
            padding-top: 5px;
            line-height: 20px;
          }
        }
      }
    }
  }

  @media screen and (min-width: 1080px) {

    .solvePlanbannerMobile {
      display: none;
    }

    .bannerBox {
      height: 51vw;
      width: 100%;
      .pageContainer {
        width: 75vw;
        margin: 0 auto;
        position: relative;
        .desc {
          position: absolute;
          left: 0;
          color: #fff;
          top: 35.4vw;
          transition: all 1s;
          &.active {
            top: 15vw;
          }
          .text1 {
            font-size: 3vw;
            line-height: 4vw;
            font-weight: bold;
          }
          .line {
            width: 5.5vw;
            border-bottom: 0.2vw solid #fff;
          }
          .text2 {
            font-size: 1.56vw;
            padding-top: 1vw;
          }
        }
      }
    }
  }

</style>
